﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using uTools;
public class LoveLoadingPanel : MonoBehaviour
{
    public RectTransform rectRoot;
    public uTweenAlpha tweenAlpha;
    public Text levelIdText;

    private void Awake()
    {
        rectRoot.gameObject.SetActive(false);
    }

    public void Show(int levelId, UnityEngine.Events.UnityAction callBack)
    {
        rectRoot.gameObject.SetActive(true);
        levelIdText.text = levelId.ToString();
        tweenAlpha.onFinished.RemoveAllListeners();
        tweenAlpha.onFinished.AddListener(() =>
        {
            callBack();
        });
        tweenAlpha.Play(PlayDirection.Forward);
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
            Hide();
    }

    public void Hide()
    {
        tweenAlpha.onFinished.RemoveAllListeners();
        tweenAlpha.onFinished.AddListener(() =>
        {
            rectRoot.gameObject.SetActive(false);
        });
        tweenAlpha.Play(PlayDirection.Reverse);
        //tweenAlpha.
    }
}
